package com.sdjnecc.myapplication;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;

public enum SocketService {
    INSTANCE;

    private DataInputStream inputStream = null;
    private DataOutputStream outputStream = null;

    public void setIOStream(final Socket socket) {

        try {
            inputStream = new DataInputStream(socket.getInputStream());
            outputStream = new DataOutputStream(socket.getOutputStream());
            outputStream.writeUTF("安卓: 你好猪娃！");
            outputStream.flush();

            String msg = inputStream.readUTF();
            System.out.println(msg);

            outputStream.close();
            inputStream.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}